# class Solution:
#     def __init__(self):
#         self.list_coin = {}
#
#     def add_list_coin(self,value):
#         if not self.list_coin.get(value):
#             self.list_coin[value] = 1
#         else:
#             self.list_coin[value] += 1
#
#     def coinChangeCore(self, coins,amount,num_path,list_path):
#         for value in coins:
#             if value > amount:
#                 continue
#             elif value == amount:
#                 self.add_list_coin(value)
#                 list_path.append(num_path+1)
#                 return True
#             if self.coinChangeCore(coins,amount-value,num_path+1,list_path):
#                 self.add_list_coin(value)
#                 return True
#         return False
#
#     def coinChange(self, coins, amount):
#         """
#         :type coins: List[int]
#         :type amount: int
#         :rtype: int
#         """
#         if amount==0:
#             return 0
#         list_path = []
#         coins.sort(reverse=True)
#         self.coinChangeCore(coins,amount,0,list_path)
#         if len(list_path) == 0:
#             return -1
#         return min(list_path)
import copy


class Solution:
    def __init__(self):
        self.list_coin = []
        
    def coinChangeCore(self, coins, amount, coins_num, list_num,coins_list):
        if amount == 0:
            if list_num[0] > coins_num:
                list_num[0] = coins_num
            self.list_coin=coins_list
            return True
        elif amount < 0:
            return False
        elif len(coins) == 0:
            return False
        num = amount // coins[-1] + 1
        for i in range(num)[::-1]:
            remainder = amount - coins[-1] * i
            if coins_num + i >= list_num[0]:
                return
            coins_list.append(coins[-1])
            self.coinChangeCore(coins[:-1], remainder, coins_num + i, list_num,copy.copy(coins_list))
    
    def coinChange(self, coins, amount):
        """
        :type coins: List[int]
        :type amount: int
        :rtype: int
        """
        remainder = amount - amount // coins[-1] * coins[-1]
        list_num = [21473648]
        coins.sort()
        self.coinChangeCore(coins, amount, 0, list_num,[])
        if list_num[0] != 21473648:
            return list_num[0]
        else:
            return -1
    
if __name__ == '__main__':
    m,n = [int(value) for value in input().split(" ")]
    coins = []
    for i in range(n):
        coins.append(int(input()))
    sol = Solution()
    result=[]
    for i in range(1,m+1):
        n = sol.coinChange(coins,amount=i)
        if n== -1:
            print(-1)
        result.append(sol.list_coin)
    if -1 in result:
        print(-1)
    print(sol.list_coin)
    for coin in coins:
        if not coin in sol.list_coin:
            result+=1
    print(result)